package org.mspring.mlog.search;

import cn.mspring.nbee.search.SearchEntity;
import cn.mspring.nbee.search.annotation.Searchable;
import cn.mspring.nbee.search.annotation.SearchableField;
import cn.mspring.nbee.search.common.SearchFieldType;
import org.mspring.mlog.entity.ArticleEntity;

import java.util.Date;

/**
 * @author Gao Youbo
 * @since 2015-10-25 22:19
 */
@Searchable(name = "article")
public class ArticleSearchEntity extends SearchEntity {
    @SearchableField(type = SearchFieldType.Long)
    private long id;
    @SearchableField
    private long category;
    @SearchableField
    private String title;
    @SearchableField
    private String content;
    @SearchableField
    private int status;
    @SearchableField
    private Date createTime;

    public static ArticleSearchEntity fromEntity(ArticleEntity entity) {
        ArticleSearchEntity searchEntity = new ArticleSearchEntity();
        searchEntity.setId(entity.getId());
        searchEntity.setCategory(entity.getCategory());
        searchEntity.setTitle(entity.getTitle());
        searchEntity.setContent(entity.getContent());
        searchEntity.setStatus(entity.getStatus());
        searchEntity.setCreateTime(entity.getCreateTime());
        return searchEntity;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public long getCategory() {
        return category;
    }

    public void setCategory(long category) {
        this.category = category;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}
